<?php

namespace Api\Controller;

use Think\Controller;
use Common\Util\Express;

class ExpressController extends BaseController 
{

	public function  __construct()
    {
        parent::__construct();
    }

    public function getExpressList(){
    	$url = SITE_URL;
		$user_id = $this->user_id;
		$where['d.user_id'] = $user_id;

		// 查询快递名称和快递单号
	    $expressInfo = M('delivery_doc as d')
	    			 ->field('d.shipping_name,d.invoice_no,d.order_sn,og.goods_id,og.goods_name,g.original_img,o.shipping_status')
	    			 ->where($where)
	    			 ->join('ln_order as o on o.order_id=d.order_id')
	    			 ->join('ln_order_goods as og on og.order_id=d.order_id')
	    			 ->join('ln_goods as g on g.goods_id=og.goods_id')
					 ->select();
		foreach( $expressInfo as $k => &$v)
		{
			$v['original_img'] = parseMediaUrl($v['original_img']);
		}
	    $this->returnInfo('1','获取成功',$expressInfo);		        
	}

    
	public function query()
	{
		$invoice_no = I('invoice_no');
		$res = Express::query($invoice_no);

		if($res)
			$this->returnInfo("1","查询成功",$res);

		$this->returnInfo("-1","未查询到物流信息","");

		// echo json_encode($res,JSON_UNESCAPED_UNICODE);
	}


	
}